#include "camera.h"

Camera::Camera()
{
    m_distanceToCenter = 15;

    m_angleZ = 0;
    m_angleY = 0;
    m_vitesse = 3;
}

QMatrix4x4 Camera::view()
{
    camera.setToIdentity();
    camera.translate(-m_distanceToCenter,0.0,0.0);
    camera.rotate(m_angleY,QVector3D(0.0, 1.0,0.0) );
    camera.rotate(m_angleZ,QVector3D(0.0, 0.0,1.0) );
    return camera;
}


QVector4D Camera::origine()
{
    QVector4D result(0,0,m_distanceToCenter,1.0);
    /*QMatrix4x4 rotation;
    rotation.rotate(-angleY%180,QVector3D(1.f, 0.f,0.f) );
    rotation.rotate(angleX,QVector3D(0.f, 1.f,0.f) );
    result = rotation * result;*/
    return result;
}

void Camera::up()
{
    m_angleY += m_vitesse;
}

void Camera::down()
{
    m_angleY -= m_vitesse;
}

void Camera::droite()
{
    m_angleZ += m_vitesse;
}

void Camera::gauche()
{
    m_angleZ -= m_vitesse;
}

void Camera::zoomAvant()
{
    m_distanceToCenter++;
}

void Camera::zoomArriere()
{
    m_distanceToCenter--;
}
